define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form, undefined) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/gongzi/index',
                    add_url: 'dahui/gongzi/add',
                    edit_url: 'dahui/gongzi/edit',
                    audit_url: 'dahui/gongzi/audit',
                    del_url: 'dahui/gongzi/del',
                    multi_url: 'dahui/gongzi/multi',
                    table: 'dahui_gongzi',
                }
            });

            var table = $("#table");

            //给添加按钮添加`data-area`属性
            $(".btn-add").data("area", ["100%", "100%"]);
            //当内容渲染完成给编辑按钮添加`data-area`属性
            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                $(".btn-editone").data("area", ["100%", "100%"]);
                $(".btn-auditone").data("area", ["100%", "100%"]);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                showToggle: false,
                search: false,
                sortName: 'id',
                dblClickToEdit: false, //是否启用双击编辑
                searchFormVisible: true,
                showExport: Config.dahui,
                exportTypes: ['csv'],
                exportOptions: {
                    //ignoreColumn: ['operate'],
                    mso:{
                        onMsoNumberFormat: function (cell, row, col) {
                            //return !isNaN($(cell).text())?'\\@':'';
                            return '\\@';
                        }
                    }
                },
                columns: [
                    [
                        //{checkbox: true},
                        //{field: 'id', title: __('Id'), operate: false, sortable: true},
                        {field: 'auditstatus', title: __('Auditstatus'), searchList: {"已审核":__('已审核'),"未审核":__('未审核')}, formatter: Table.api.formatter.normal},
                        {field: 'preprocessing', title: __('Preprocessing'), searchList: {"":__(''),"是":__('是') }, formatter: Table.api.formatter.normal, sortable: true},
                        {field: 'orderdate', title: __('录入日期'), defaultValue: Controller.api.defaultdate2(), operate:'RANGE', addclass:'datetimerange', sortable: true},
                        {field: 'opyear', title: __('操作年月'), addclass:'datetimepicker', formatter: Table.api.formatter.search},
                        {field: 'taobaoname', title: __('Taobaoname'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'ownedcompany', title: __('所属公司'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'idnumber', title: __('身份证号*'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: function (value, row, index) {
                            //JSON.stringify(row)
                            return [
                                '<a href="/admin/dahui/gongzi/index1?idnumber=' + row.idnumber + '&ref=addtabs" target="_parent" >' + row.idnumber + '</a>'
                            ].join("")
                        }},
                        {field: 'kehu.name', title: __('Kehu.name'), operate: false, formatter: Table.api.formatter.search, sortable: true},
                        {field: 'kehu.mobile', title: __('Kehu.mobile'), operate: false, formatter: function (value, row, index) {

                            return [
                                '<a href="javascript:;" class="btn btn-xs">' + value + '</a>'
                            ].join("")

                        }},
                        {
                            field: 'kehu.bankcardnumber',
                            title: __('Kehu.bankcardnumber'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: 'LIKE %...%',
                            placeholder: '模糊搜索，*表示任意字符',
                            sortable: true
                        },

                        {field: 'payyear', title: __('Payyear'), operate:false},
                        {
                            field: 'agencyfees',
                            title: __('Agencyfees'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: 'false',
                            sortable: true
                        },

                        //{field: 'paystatus', title: __('Paystatus'), searchList: {"已办理":__('已办理'),"未办理":__('未办理'),"":__('')}, formatter: Table.api.formatter.status, sortable: true},
                        //{field: 'refundornot', title: __('Refundornot'), searchList: {"":__(''),"已退款":__('已退款'),"待退款":__('待退款'),"需退款":__('需退款')}, formatter: Table.api.formatter.normal, sortable: true},
                        {field: 'sbbase', title: __('Sbbase'),operate:false},
                        {field: 'gjjbase', title: __('Gjjbase'),operate:false},
                        {field: 'totalwages', title: __('Totalwages'),operate:false},//工资总额
                        {field: 'r_wages', title: __('R_wages'), operate:false},//实发工资


                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Controller.api.events.operate,
                            formatter: function (value, row, index) {
                                var table = this.table;
                                // 操作配置
                                var options = table ? table.bootstrapTable('getOptions') : {};
                                // 默认按钮组
                                var buttons = $.extend([], this.buttons || []);
                                // 所有按钮名称
                                var names = [];
                                buttons.forEach(function (item) {
                                    names.push(item.name);
                                });
                                if (options.extend.edit_url !== '' && names.indexOf('edit') === -1 && row.auditstatus == "未审核" && Config.luru) {
                                    buttons.push({
                                        name: 'edit',
                                        icon: 'fa fa-pencil',
                                        title: __('修改'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-success btn-editone',
                                        url: options.extend.edit_url
                                    });
                                }

                                if (options.extend.audit_url !== '' && names.indexOf('audit') === -1 && row.auditstatus == "未审核" && Config.audit) {
                                    buttons.push({
                                        name: 'audit',
                                        icon: 'fa fa-gavel',
                                        title: __('审核'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-success btn-auditone',
                                        url: options.extend.audit_url
                                    });
                                }

                                if (options.extend.del_url !== '' && names.indexOf('del') === -1 && row.auditstatus == "未审核") {
                                    buttons.push({
                                        name: 'del',
                                        icon: 'fa fa-trash',
                                        title: __('Del'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-danger btn-delone'
                                    });
                                }
                                return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
                            }
                        },
                    ]
                ]
            });

            $('a[data-toggle="tab"]').on("shown.bs.tab", function (e) {
                var value = $(e.target).data('value');
                console.log(value);
                //$("select[name='businesstype'] option[value='" + "个税" + "']", table.closest(".bootstrap-table").find(".commonsearch-table")).prop("selected", true);

                var options = table.bootstrapTable('getOptions');
                options.pageNumber = 1;
                options.queryParams = function(params) {
                    params.filter = JSON.stringify({businesstype: "个税"});
                    params.op = JSON.stringify({businesstype: "="});
                    //params.type = value;
                    //params.businesstype = "个税";
                    return params;
                };

                table.bootstrapTable('refresh', {});

            });

            var form = $("form.form-commonsearch");
            if ($(".datetimepicker", form).size() > 0) {
                require(['bootstrap-datetimepicker'], function () {
                    var options = {
                        format: 'YYYY-MM',
                        icons: {
                            time: 'fa fa-clock-o',
                            date: 'fa fa-calendar',
                            up: 'fa fa-chevron-up',
                            down: 'fa fa-chevron-down',
                            previous: 'fa fa-chevron-left',
                            next: 'fa fa-chevron-right',
                            today: 'fa fa-history',
                            clear: 'fa fa-trash',
                            close: 'fa fa-remove'
                        },
                        showTodayButton: true,
                        showClose: true
                    };
                    $('.datetimepicker', form).parent().css('position', 'relative');
                    $('.datetimepicker', form).datetimepicker(options);
                });
            }

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        index1: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/gongzi/index1',
                    add_url: '',
                    edit_url: 'dahui/gongzi/edit1',
                    del_url: 'dahui/gongzi/del',
                    multi_url: '',
                    table: 'dahui_dingdan1',
                }
            });

            var table = $("#table");
            var idnumber = '';

            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                $(".btn-editone").data("area", ["50%", "50%"]);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                showToggle: false,
                sortName: 'id',
                searchFormVisible: true,
                showExport: Config.dahui,
                exportTypes: ['csv'],
                exportOptions: {
                    //ignoreColumn: ['operate'],
                    mso:{
                        onMsoNumberFormat: function (cell, row, col) {
                            //return !isNaN($(cell).text())?'\\@':'';
                            return '\\@';
                        }
                    }
                },
                showColumns: false,
                search: false,
                dblClickToEdit: false, //是否启用双击编辑
                columns: [
                    [
                        //{checkbox: true},
                        {field: 'opyear', title: __('操作年月'), operate:false},
                        {field: 'taobaoname', title: __('Taobaoname'),  operate:false},
                        {field: 'ownedcompany', title: __('所属公司'), operate: false},
                        {field: 'kehu.name', title: __('Kehu.name'), operate: false},
                        {
                            field: 'kehu.mobile',
                            title: __('客户电话*'),
                            editable: {
                                emptytext: '无',
                                disabled: !Config.audit,
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: false
                        },
                        {
                            field: 'kehu.bankcardnumber',
                            title: __('银行卡号*'),
                            editable: {
                                emptytext: '无',
                                disabled: !Config.audit, //true 则不能编辑 ---- 操作权限
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: false
                        },
                        {field: 'payyear', title: __('Payyear'), operate: false},
                        {field: 'agencyfees', title: __('Agencyfees'), operate: false},
                        {field: 'sbbase', title: __('Sbbase'), operate: false},
                        {field: 'gjjbase', title: __('Gjjbase'), operate: false},
                        {field: 'totalwages', title: __('Totalwages'), operate: false},
                        {field: 'r_wages', title: __('R_wages'), operate: false},
                        {field: 'refundornot', title: __('是否退款*'), operate:false, formatter: Controller.api.formatter.tkstatus},

                        {field: 'idnumber', title: __('idnumber'), visible:false},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: function (value, row, index) {
                                var table = this.table;
                                // 操作配置
                                var options = table ? table.bootstrapTable('getOptions') : {};
                                // 默认按钮组
                                var buttons = $.extend([], this.buttons || []);
                                // 所有按钮名称
                                var names = [];
                                buttons.forEach(function (item) {
                                    names.push(item.name);
                                });
                                if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
                                    buttons.push({
                                        name: 'dragsort',
                                        icon: 'fa fa-arrows',
                                        title: __('Drag to sort'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-primary btn-dragsort'
                                    });
                                }
                                if (options.extend.del_url !== '' && names.indexOf('del') === -1 && Config.audit && Config.luru && Config.caozuo) {
                                    buttons.push({
                                        name: 'del',
                                        icon: 'fa fa-trash',
                                        title: __('Del'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-danger btn-delone'
                                    });
                                }
                                return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
                            }
                        },

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                idnumber = data.idnumber;
                var note = data.note;
                if (note == null || note.length < 1) {
                    note = "*客户备注";
                }
                $("#c_note").text(note);
            });

            $(document).on('click', '.beizu', function () {
                //获取选中的条目ID集合
                if (Config.audit) {
                    var url = 'dahui/gongzi/editkehunote?idnumber=' + idnumber;//弹出窗口 add.html页面的（fastadmin封装layer模态框将以iframe的方式将add输出到index页面的模态框里）

                    var options = {
                        shadeClose: false,
                        shade: [0.3, '#393D49'],
                        area: ["60%", "60%"],
                        callback:function(data){
                            //CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                            $("#c_note").text(data);
                            //$(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open(url, "客户备注", options);
                }
            });

            //点击退款状态
            $(document).on("dblclick", ".tkstatus[data-id]", function () {
                if (Config.caozuo || Config.audit) {
                    var url = 'dahui/gongzi/changetstatus';
                    var id = $(this).data('id');
                    var _this = $(this);
                    Fast.api.ajax({
                        url: url,
                        data: {ids: id},
                    }, function (data, ret) {
                        //table.bootstrapTable('refresh');
                        console.log(ret.data.refundornot);
                        _this.removeClass('text-success')
                        _this.removeClass('text-warning')
                        _this.removeClass('text-danger')
                        if (ret.data.refundornot == '已退款') {
                            _this.addClass('text-success');
                            _this.html(ret.data.refundornot);
                        } else if (ret.data.refundornot == '待退款') {
                            _this.addClass('text-warning');
                            _this.html(ret.data.refundornot);
                        } else if (ret.data.refundornot == '需退款') {
                            _this.addClass('text-danger');
                            _this.html(ret.data.refundornot);
                        } else {
                            _this.html('--');
                        }
                    });
                }
            });

        },
        index2: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/gongzi/index2',
                    add_url: '',
                    edit_url: 'dahui/gongzi/edit2',
                    del_url: 'dahui/gongzi/del2',
                    multi_url: '',
                    table: 'dahui_gongzi',
                }
            });

            var table = $("#table");

            //给添加按钮添加`data-area`属性
            $(".btn-add").data("area", ["100%", "100%"]);
            //当内容渲染完成给编辑按钮添加`data-area`属性
            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                $(".btn-editone").data("area", ["100%", "100%"]);
            });
            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                $("#money").text(data.extend.money);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                showToggle: false,
                search: false,
                sortName: 'id',
                showExport: Config.dahui,
                dblClickToEdit: false, //是否启用双击编辑
                searchFormVisible: true,
                exportTypes: ['csv'],
                exportOptions: {
                    //ignoreColumn: ['operate'],
                    mso:{
                        onMsoNumberFormat: function (cell, row, col) {
                            //return !isNaN($(cell).text())?'\\@':'';
                            return '\\@';
                        }
                    }
                },
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate: false, sortable: true},
                        {field: 'paystatus', title: __('Paystatus'), searchList: {"已办理":__('已办理'),"未办理":__('未办理'), "办理失败":__('办理失败')}, formatter: Controller.api.formatter.paystatus},
                        {field: 'opyear', title: __('操作年月'), defaultValue: Controller.api.defaultdate(), addclass:'datetimepicker', formatter: Table.api.formatter.search},
                        {field: 'taobaoname', title: __('Taobaoname'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'ownedcompany', title: __('所属公司'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'idnumber', title: __('身份证号*'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: function (value, row, index) {
                            //JSON.stringify(row)
                            return [
                                '<a href="/admin/dahui/gongzi/index1?idnumber=' + row.idnumber + '&ref=addtabs" target="_parent" >' + row.idnumber + '</a>'
                            ].join("")
                        }},
                        {field: 'kehu.name', title: __('Kehu.name'), operate: false, formatter: Table.api.formatter.search, sortable: true},
                        {field: 'kehu.mobile', title: __('Kehu.mobile'), operate: false, formatter: function (value, row, index) {

                            return [
                                '<a href="javascript:;" class="btn btn-xs">' + value + '</a>'
                            ].join("")

                        }},
                        {field: 'kehu.bankcardnumber', title: __('Kehu.bankcardnumber'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'payyear', title: __('Payyear'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        //{field: 'agencyfees', title: __('Agencyfees'), operate:false},
                        {field: 'sbbase', title: __('Sbbase'),operate:false},
                        {field: 'gjjbase', title: __('Gjjbase'),operate:false},
                        {field: 'y_wages', title: __('应发工资'),operate:false},
                        {field: 'tax', title: __('个税'),operate:false},
                        {field: 'r_wages', title: __('实发工资'), operate:false},
                        {
                            field: 'paynote',
                            title: __('代缴备注*'),
                            editable: {
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                emptytext: '无',
                                disabled: !Config.caozuo , //true 则不能编辑 ---- 操作权限
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: false
                        },
                        {
                            field: 'agencyfees',
                            title: __('Agencyfees'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: 'false',
                            sortable: true
                        },

                    ]
                ]
            });

            $('a[data-toggle="tab"]').on("shown.bs.tab", function (e) {
                var value = $(e.target).data('value');
                console.log(value);
                //$("select[name='businesstype'] option[value='" + "个税" + "']", table.closest(".bootstrap-table").find(".commonsearch-table")).prop("selected", true);

                var options = table.bootstrapTable('getOptions');
                options.pageNumber = 1;
                options.queryParams = function(params) {
                    params.filter = JSON.stringify({businesstype: "个税"});
                    params.op = JSON.stringify({businesstype: "="});
                    //params.type = value;
                    //params.businesstype = "个税";
                    return params;
                };

                table.bootstrapTable('refresh', {});

            });

            var form = $("form.form-commonsearch");
            if ($(".datetimepicker", form).size() > 0) {
                require(['bootstrap-datetimepicker'], function () {
                    var options = {
                        format: 'YYYY-MM',
                        icons: {
                            time: 'fa fa-clock-o',
                            date: 'fa fa-calendar',
                            up: 'fa fa-chevron-up',
                            down: 'fa fa-chevron-down',
                            previous: 'fa fa-chevron-left',
                            next: 'fa fa-chevron-right',
                            today: 'fa fa-history',
                            clear: 'fa fa-trash',
                            close: 'fa fa-remove'
                        },
                        showTodayButton: true,
                        showClose: true
                    };
                    $('.datetimepicker', form).parent().css('position', 'relative');
                    $('.datetimepicker', form).datetimepicker(options);
                });
            }

            //点击代缴状态
            $(document).on("dblclick", ".paystatus[data-id]", function () {
                if (Config.caozuo) {
                    var url = 'dahui/gongzi/changepaystatus';
                    var id = $(this).data('id');
                    var _this = $(this);
                    Fast.api.ajax({
                        url: url,
                        data: {ids: id},
                    }, function (data, ret) {
                        console.log(ret.data.paystatus);
                        _this.html(ret.data.paystatus);
                        if (ret.data.paystatus == '未办理' || ret.data.paystatus == '办理失败') {
                            _this.addClass('text-danger');
                        }  else {
                            _this.removeClass('text-danger')
                        }
                    });
                }

            });

            // 批量代缴状态
            $(document).on("click", ".pldjzt0", function () {
                if (Config.caozuo) {
                    var ids = Table.api.selectedids(table);
                    var url = 'dahui/gongzi/pldjzt0?ids=' + ids;

                    var that = this;
                    Layer.confirm(__('批量代缴状态 => "已办理"?'), {icon: 3, title: '提示'}, function (index) {
                        Backend.api.ajax({
                            url: url,
                        }, function () {
                            Layer.close(index);
                            $(".btn-refresh").trigger("click");
                        });
                    });
                }
            });

            // 批量代缴状态
            $(document).on("click", ".pldjzt1", function () {
                if (Config.caozuo) {
                    var ids = Table.api.selectedids(table);
                    var url = 'dahui/gongzi/pldjzt1?ids=' + ids;

                    var that = this;
                    Layer.confirm(__('批量代缴状态 => "未办理"?'), {icon: 3, title: '提示'}, function (index) {
                        Backend.api.ajax({
                            url: url,
                        }, function () {
                            Layer.close(index);
                            $(".btn-refresh").trigger("click");
                        });
                    });
                }
            });

            // 批量代缴状态
            $(document).on("click", ".pldjzt2", function () {
                if (Config.caozuo) {
                    var ids = Table.api.selectedids(table);
                    var url = 'dahui/gongzi/pldjzt2?ids=' + ids;

                    var that = this;
                    Layer.confirm(__('批量代缴状态 => "办理失败"?'), {icon: 3, title: '提示'}, function (index) {
                        Backend.api.ajax({
                            url: url,
                        }, function () {
                            Layer.close(index);
                            $(".btn-refresh").trigger("click");
                        });
                    });
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        index3: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'dahui/gongzi/index3',
                    add_url: '',
                    edit_url: 'dahui/gongzi/edit',
                    del_url: 'dahui/gongzi/del',
                    multi_url: '',
                    table: 'dahui_gongzi',
                }
            });

            var table = $("#table");

            //给添加按钮添加`data-area`属性
            $(".btn-add").data("area", ["100%", "100%"]);
            //当内容渲染完成给编辑按钮添加`data-area`属性
            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                $(".btn-editone").data("area", ["100%", "100%"]);
                $(".btn-auditone").data("area", ["100%", "100%"]);
            });

            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                $("#money").text(data.extend.money);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                showToggle: false,
                search: false,
                sortName: 'id',
                dblClickToEdit: false, //是否启用双击编辑
                searchFormVisible: true,
                showExport: Config.dahui,
                exportTypes: ['csv'],
                exportOptions: {
                    //ignoreColumn: ['operate'],
                    mso:{
                        onMsoNumberFormat: function (cell, row, col) {
                            //return !isNaN($(cell).text())?'\\@':'';
                            return '\\@';
                        }
                    }
                },
                columns: [
                    [
                        //{checkbox: true},
                        //{field: 'id', title: __('Id'), operate: false, sortable: true},
                        //{field: 'auditstatus', title: __('Auditstatus'), searchList: {"已审核":__('已审核'),"未审核":__('未审核')}, formatter: Table.api.formatter.normal},
                        //{field: 'preprocessing', title: __('Preprocessing'), searchList: {"":__(''),"是":__('是') }, formatter: Table.api.formatter.normal, sortable: true},
                        {field: 'opyear', title: __('操作年月'), defaultValue: Controller.api.defaultdate(), addclass:'datetimepicker', formatter: Table.api.formatter.search},
                        {field: 'taobaoname', title: __('Taobaoname'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'ownedcompany', title: __('所属公司'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'idnumber', title: __('身份证号*'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: function (value, row, index) {
                            //JSON.stringify(row)
                            return [
                                '<a href="/admin/dahui/gongzi/index1?idnumber=' + row.idnumber + '&ref=addtabs" target="_parent" >' + row.idnumber + '</a>'
                            ].join("")
                        }},
                        {field: 'kehu.name', title: __('Kehu.name'), operate: false, formatter: Table.api.formatter.search, sortable: true},
                        {field: 'kehu.mobile', title: __('Kehu.mobile'), operate: false, formatter: function (value, row, index) {

                            return [
                                '<a href="javascript:;" class="btn btn-xs">' + value + '</a>'
                            ].join("")

                        }},
                        {field: 'kehu.bankcardnumber', title: __('Kehu.bankcardnumber'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符', formatter: Table.api.formatter.search, sortable: true},
                        {field: 'payyear', title: __('Payyear'), operate:false},
                        {field: 'agencyfees', title: __('Agencyfees'), operate:false},
                        {field: 'sbbase', title: __('Sbbase'),operate:false},
                        {field: 'gjjbase', title: __('Gjjbase'),operate:false},
                        {field: 'totalwages', title: __('Totalwages'),operate:false},
                        {field: 'r_wages', title: __('R_wages'), operate:false},
                        {field: 'refundornot', title: __('Refundornot'), searchList: {"已退款":__('已退款'),"待退款":__('待退款'),"需退款":__('需退款')}, formatter: Controller.api.formatter.tkstatus},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: function (value, row, index) {
                                var table = this.table;
                                // 操作配置
                                var options = table ? table.bootstrapTable('getOptions') : {};
                                // 默认按钮组
                                var buttons = $.extend([], this.buttons || []);
                                // 所有按钮名称
                                var names = [];
                                buttons.forEach(function (item) {
                                    names.push(item.name);
                                });
                                if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
                                    buttons.push({
                                        name: 'dragsort',
                                        icon: 'fa fa-arrows',
                                        title: __('Drag to sort'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-primary btn-dragsort'
                                    });
                                }
                                if (options.extend.edit_url !== '' && names.indexOf('edit') === -1 && row.auditstatus == "未审核") {
                                    buttons.push({
                                        name: 'edit',
                                        icon: 'fa fa-gavel',
                                        title: __('审核'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-success btn-editone',
                                        url: options.extend.edit_url
                                    });
                                }
                                if (options.extend.del_url !== '' && names.indexOf('del') === -1 && row.auditstatus == "未审核") {
                                    buttons.push({
                                        name: 'del',
                                        icon: 'fa fa-trash',
                                        title: __('Del'),
                                        extend: 'data-toggle="tooltip"',
                                        classname: 'btn btn-xs btn-danger btn-delone'
                                    });
                                }
                                return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
                            }
                        },
                    ]
                ]
            });

            $('a[data-toggle="tab"]').on("shown.bs.tab", function (e) {
                var value = $(e.target).data('value');
                console.log(value);
                //$("select[name='businesstype'] option[value='" + "个税" + "']", table.closest(".bootstrap-table").find(".commonsearch-table")).prop("selected", true);

                var options = table.bootstrapTable('getOptions');
                options.pageNumber = 1;
                options.queryParams = function(params) {
                    params.filter = JSON.stringify({businesstype: "个税"});
                    params.op = JSON.stringify({businesstype: "="});
                    //params.type = value;
                    //params.businesstype = "个税";
                    return params;
                };

                table.bootstrapTable('refresh', {});

            });

            var form = $("form.form-commonsearch");
            if ($(".datetimepicker", form).size() > 0) {
                require(['bootstrap-datetimepicker'], function () {
                    var options = {
                        format: 'YYYY-MM',
                        icons: {
                            time: 'fa fa-clock-o',
                            date: 'fa fa-calendar',
                            up: 'fa fa-chevron-up',
                            down: 'fa fa-chevron-down',
                            previous: 'fa fa-chevron-left',
                            next: 'fa fa-chevron-right',
                            today: 'fa fa-history',
                            clear: 'fa fa-trash',
                            close: 'fa fa-remove'
                        },
                        showTodayButton: true,
                        showClose: true
                    };
                    $('.datetimepicker', form).parent().css('position', 'relative');
                    $('.datetimepicker', form).datetimepicker(options);
                });
            }

            //点击退款状态
            $(document).on("dblclick", ".tkstatus[data-id]", function () {
                if (Config.caozuo) {
                    var url = 'dahui/gongzi/changetstatus';
                    var id = $(this).data('id');
                    var _this = $(this);
                    Fast.api.ajax({
                        url: url,
                        data: {ids: id},
                    }, function (data, ret) {
                        //table.bootstrapTable('refresh');
                        console.log(ret.data.refundornot);
                        _this.removeClass('text-success')
                        _this.removeClass('text-warning')
                        _this.removeClass('text-danger')
                        if (ret.data.refundornot == '已退款') {
                            _this.addClass('text-success');
                            _this.html(ret.data.refundornot);
                        } else if (ret.data.refundornot == '待退款') {
                            _this.addClass('text-warning');
                            _this.html(ret.data.refundornot);
                        } else if (ret.data.refundornot == '需退款') {
                            _this.addClass('text-danger');
                            _this.html(ret.data.refundornot);
                        } else {
                            _this.html('--');
                        }
                    });
                } else if (Config.tuikuan) {
                    var url = 'dahui/gongzi/changetstatus4';
                    var id = $(this).data('id');
                    var _this = $(this);
                    Fast.api.ajax({
                        url: url,
                        data: {ids: id},
                    }, function (data, ret) {
                        //table.bootstrapTable('refresh');
                        console.log(ret.data.refundornot);
                        _this.removeClass('text-success')
                        _this.removeClass('text-warning')
                        _this.removeClass('text-danger')
                        if (ret.data.refundornot == '已退款') {
                            _this.addClass('text-success');
                            _this.html(ret.data.refundornot);
                        } else if (ret.data.refundornot == '待退款') {
                            _this.addClass('text-warning');
                            _this.html(ret.data.refundornot);
                        } else if (ret.data.refundornot == '需退款') {
                            _this.addClass('text-danger');
                            _this.html(ret.data.refundornot);
                        } else {
                            _this.html('--');
                        }
                    });
                }
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        gzls: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url2: 'dahui/gongzi/gzls?taobaoname=' + Config.taobaoname + "&idnumber=" + Config.idnumber,
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: '',
                    table: 'dahui_gzls',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url2,
                pk: 'id',
                sortName: 'id',
                search:false,
                showToggle: false,
                showColumns: false,
                commonSearch: false,
                showExport: false,
                columns: [
                    [
                        {
                            field: 'buttons',
                            width: "60px",
                            title: __('操作'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: '加入',
                                    text: __('加入'),
                                    title: __('加入选中记录'),
                                    classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                    icon: 'fa fa-magic',
                                    url: 'dahui/gongzi/addhis',
                                    success: function (data, ret) {
                                        //Layer.alert(ret.msg + ",返回数据：" + JSON.stringify(data));
                                        //如果需要阻止成功提示，则必须使用return false;
                                        Fast.api.close(data);
                                        return false;
                                    },
                                    error: function (data, ret) {
                                        console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    }
                                }
                            ],
                            formatter: Table.api.formatter.buttons
                        },
                        {field: 'opyear', title: __('操作年月'), operate:false},
                        {field: 'taobaoname', title: __('Taobaoname'),  operate:false},
                        {field: 'idnumber', title: __('身份证号'), operate:false},
                        {field: 'kehu.name', title: __('Kehu.name'), operate: false},
                        {field: 'kehu.mobile', title: __('Kehu.mobile'), formatter: function (value, row, index) {

                            return [
                                '<a href="javascript:;" class="btn btn-xs">' + value + '</a>'
                            ].join("")

                        }},
                        {field: 'kehu.bankcardnumber', title: __('Kehu.bankcardnumber'), operate: false},
                        {field: 'payyear', title: __('Payyear'), operate: false},
                        {field: 'agencyfees', title: __('Agencyfees'), operate: false},
                        {field: 'sbbase', title: __('Sbbase'), operate: false},
                        {field: 'gjjbase', title: __('Gjjbase'), operate: false},
                        {field: 'totalwages', title: __('Totalwages'), operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

        },
        dingdanuserinfo: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url2: 'dahui/gongzi/dingdanuserinfo?taobaoname=' + Config.taobaoname,
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: '',
                    table: 'dahui_dingdanuserinfo',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url2,
                pk: 'id',
                sortName: 'id',
                search:false,
                showToggle: false,
                showColumns: false,
                commonSearch: false,
                showExport: false,
                columns: [
                    [
                        {
                            field: 'buttons',
                            width: "60px",
                            title: __('操作'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: '加入',
                                    text: __('加入'),
                                    title: __('加入选中记录'),
                                    classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                    icon: 'fa fa-magic',
                                    url: 'dahui/gongzi/adddduser',
                                    success: function (data, ret) {
                                        //Layer.alert(ret.msg + ",返回数据：" + JSON.stringify(data));
                                        //如果需要阻止成功提示，则必须使用return false;
                                        Fast.api.close(data);
                                        return false;
                                    },
                                    error: function (data, ret) {
                                        console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    }
                                }
                            ],
                            formatter: Table.api.formatter.buttons
                        },
                        {field: 'taobaoname', title: __('Taobaoname'),  operate:false},
                        {field: 'idnumber', title: __('身份证号'), operate:false},
                        {field: 'name', title: __('姓名'), operate:false},
                        {field: 'mobile', title: __('电话'), operate:false, formatter: function (value, row, index) {

                            return [
                                '<a href="javascript:;" class="btn btn-xs">' + value + '</a>'
                            ].join("")

                        }},
                        {field: 'bankcardnumber', title: __('银行卡号'), operate:false},
                        {field: 'payingcompany', title: __('所属公司'), operate:false},
                        {field: 'sbbase', title: __('社保基数'), operate: false},
                        {field: 'gjjbase', title: __('公积金基数'), operate: false},
                        {field: 'tax', title: __('个税'), operate: false},
                        {field: 'opyear', title: __('上次操作年月'), operate: false},
                        {field: 'payyear', title: __('上次代缴年月'), operate: false},
                        {field: 'totalwages', title: __('上次实发工资'), operate: false},
                        {field: 'agencyfees', title: __('上次付代理费'), operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

        },
        add: function () {

            //$("#c-idnumber").keypress(function (e) {
            //    if (e.which == 13) {
            //        var idnumber = $("#c-idnumber").val();
            //        if (idnumber.length > 1) {
            //            var url = "/admin/dahui/gongzi/gzls?idnumber=" + idnumber;
            //            var options = {
            //                shadeClose: false,
            //                shade: [0.3, '#393D49'],
            //                area: ["100%", "100%"],
            //                callback:function(data){
            //                    //CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
            //                    $("#c-idnumber").val(data.idnumber);
            //                    $("#c-name").val(data.kehu.name);
            //                    $("#c-mobile").val(data.kehu.mobile);
            //                    $("#c-bankcardnumber").val(data.kehu.bankcardnumber);
            //                    if (data.sbbase < 1 || data.gjjbase < 1) {
            //                        data.sbbase = Config.minimumcardinality;
            //                        data.gjjbase = Config.minimumcardinality;
            //                    }
            //                    $("#c-taobaoname").val(data.taobaoname);
            //                    $("#c-sbbase").val(data.sbbase);
            //                    $("#c-gjjbase").val(data.gjjbase);
            //                    $("#c-totalwages").val(data.totalwages);
            //                    $("#c-idnumber").focusout();//移除焦点
            //                }
            //            };
            //            Fast.api.open(url, "工资缴纳记录", options);
            //        }
            //    }
            //});

            $("#c-taobaoname").keypress(function (e) {
                if (e.which == 13) {
                    var taobaoname = $("#c-taobaoname").val();
                    if (taobaoname.length > 1) {
                        url = "/admin/dahui/gongzi/dingdanuserinfo?taobaoname=" + taobaoname;
                        var options = {
                            shadeClose: false,
                            shade: [0.3, '#393D49'],
                            area: ["100%", "100%"],
                            callback:function(data){
                                $("#c-idnumber").val(data.idnumber);
                                $("#c-name").val(data.name);
                                $("#c-mobile").val(data.mobile);
                                $("#c-bankcardnumber").val(data.bankcardnumber);

                                $("#c-ownedcompany").val(data.payingcompany);
                                $("#c-taobaoname").val(data.taobaoname);
                                $("#c-sbbase").val(data.sbbase);
                                $("#c-gjjbase").val(data.gjjbase);
                                $("#c-tax").val(data.tax);
                                $("#c-payyear").val(data.payyear);
                                $("#c-r_wages").val(data.totalwages);
                                $("#c-totalwages").val(data.totalwages+data.tax);
                                $("#c-idnumber").focusout();//移除焦点
                            }
                        };
                        Fast.api.open(url, "工资缴纳记录", options);
                        return false;
                    }
                }
            });

            $(document).on("change", ".valuechanged", function () {
                Controller.api.valuechanged();
            });

            Controller.api.valuechanged();

            Controller.api.bindevent();
        },
        edit: function () {
            //$("#c-idnumber").keypress(function (e) {
            //    if (e.which == 13) {
            //        var idnumber = $("#c-idnumber").val();
            //        if (idnumber.length > 1) {
            //            var url = "/admin/dahui/gongzi/gzls?idnumber=" + idnumber;
            //            var options = {
            //                shadeClose: false,
            //                shade: [0.3, '#393D49'],
            //                area: ["100%", "100%"],
            //                callback:function(data){
            //                    //CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
            //                    $("#c-idnumber").val(data.idnumber);
            //                    $("#c-idnumber").focusout();//移除焦点
            //                    $("#c-name").val(data.kehu.name);
            //                    $("#c-mobile").val(data.kehu.mobile);
            //                    $("#c-bankcardnumber").val(data.kehu.bankcardnumber);
            //                    if (data.sbbase < 1 || data.gjjbase < 1) {
            //                        data.sbbase = Config.minimumcardinality;
            //                        data.gjjbase = Config.minimumcardinality;
            //                    }
            //                    $("#c-taobaoname").val(data.taobaoname);
            //                    $("#c-sbbase").val(data.sbbase);
            //                    $("#c-gjjbase").val(data.gjjbase);
            //                    $("#c-totalwages").val(data.totalwages);
            //                }
            //            };
            //            Fast.api.open(url, "工资缴纳记录", options);
            //        }
            //    }
            //});

            $("#c-taobaoname").keypress(function (e) {
                if (e.which == 13) {
                    var taobaoname = $("#c-taobaoname").val();
                    if (taobaoname.length > 1) {
                        var url = "/admin/dahui/gongzi/gzls?taobaoname=" + taobaoname;
                        var options = {
                            shadeClose: false,
                            shade: [0.3, '#393D49'],
                            area: ["100%", "100%"],
                            callback:function(data){
                                //CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                                $("#c-idnumber").val(data.idnumber);
                                $("#c-name").val(data.name);
                                $("#c-mobile").val(data.mobile);
                                $("#c-bankcardnumber").val(data.bankcardnumber);

                                $("#c-ownedcompany").val(data.payingcompany);
                                $("#c-taobaoname").val(data.taobaoname);
                                $("#c-sbbase").val(data.sbbase);
                                $("#c-gjjbase").val(data.gjjbase);
                                $("#c-tax").val(data.tax);
                                $("#c-payyear").val(data.payyear);
                                $("#c-r_wages").val(data.totalwages);
                                $("#c-totalwages").val(data.totalwages+data.tax);
                                $("#c-idnumber").focusout();//移除焦点
                            }
                        };
                        Fast.api.open(url, "工资缴纳记录", options);
                    }
                }
            });

            $(document).on("change", ".valuechanged", function () {
                Controller.api.valuechanged();
            });
            Controller.api.valuechanged();
            Controller.api.bindevent();
        },
        audit: function () {

            Controller.api.valuechanged();

            //$("#c-idnumber").keypress(function (e) {
            //    if (e.which == 13) {
            //        var idnumber = $("#c-idnumber").val();
            //        if (idnumber.length > 1) {
            //            var url = "/admin/dahui/gongzi/gzls?idnumber=" + idnumber;
            //            var options = {
            //                shadeClose: false,
            //                shade: [0.3, '#393D49'],
            //                area: ["100%", "100%"],
            //                callback:function(data){
            //                    //CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
            //                    $("#c-idnumber").val(data.idnumber);
            //                    $("#c-name").val(data.name);
            //                    $("#c-mobile").val(data.mobile);
            //                    $("#c-bankcardnumber").val(data.bankcardnumber);
            //
            //                    $("#c-ownedcompany").val(data.payingcompany);
            //                    $("#c-taobaoname").val(data.taobaoname);
            //                    $("#c-sbbase").val(data.sbbase);
            //                    $("#c-gjjbase").val(data.gjjbase);
            //                    $("#c-tax").val(data.tax);
            //                    $("#c-payyear").val(data.payyear);
            //                    $("#c-r_wages").val(data.totalwages);
            //                    $("#c-totalwages").val(data.totalwages+data.tax);
            //                    $("#c-idnumber").focusout();//移除焦点
            //                }
            //            };
            //            Fast.api.open(url, "工资缴纳记录", options);
            //        }
            //    }
            //});

            $("#c-taobaoname").keypress(function (e) {
                if (e.which == 13) {
                    var taobaoname = $("#c-taobaoname").val();
                    if (taobaoname.length > 1) {
                        var url = "/admin/dahui/gongzi/gzls?taobaoname=" + taobaoname;
                        var options = {
                            shadeClose: false,
                            shade: [0.3, '#393D49'],
                            area: ["100%", "100%"],
                            callback:function(data){
                                //CallBackFun(value.id, value.name);//在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                                $("#c-idnumber").val(data.idnumber);
                                $("#c-name").val(data.name);
                                $("#c-mobile").val(data.mobile);
                                $("#c-bankcardnumber").val(data.bankcardnumber);

                                $("#c-ownedcompany").val(data.payingcompany);
                                $("#c-taobaoname").val(data.taobaoname);
                                $("#c-sbbase").val(data.sbbase);
                                $("#c-gjjbase").val(data.gjjbase);
                                $("#c-tax").val(data.tax);
                                $("#c-payyear").val(data.payyear);
                                $("#c-r_wages").val(data.totalwages);
                                $("#c-totalwages").val(data.totalwages+data.tax);
                                $("#c-idnumber").focusout();//移除焦点
                            }
                        };
                        Fast.api.open(url, "工资缴纳记录", options);
                    }
                }
            });

            $(document).on("change", ".valuechanged", function () {
                Controller.api.valuechanged();
            });

            Controller.api.bindevent();
        },
        edit1: function () {
            Controller.api.bindevent();
        },
        edit2: function () {
            Controller.api.bindevent();
        },
        edit3: function () {
            Controller.api.bindevent();
        },
        editkehunote: function () {
            Controller.api.bindevent();
            $(document).on('click', '.khbz', function () {
                var data = $("#c-note").val();
                //确实从这里传入
                Fast.api.close(data);
            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            events: {//绑定事件的方法
                operate: {
                    'click .btn-editone': function (e, value, row, index) {
                        e.stopPropagation();
                        e.preventDefault();
                        var table = $(this).closest('table');
                        var options = table.bootstrapTable('getOptions');
                        var ids = row[options.pk];
                        row = $.extend({}, row ? row : {}, {ids: ids});
                        var url = options.extend.edit_url;
                        Fast.api.open(Table.api.replaceurl(url, row, table), __('Edit'), $(this).data() || {});
                    },
                    'click .btn-auditone': function (e, value, row, index) {
                        e.stopPropagation();
                        e.preventDefault();
                        var table = $(this).closest('table');
                        var options = table.bootstrapTable('getOptions');
                        var ids = row[options.pk];
                        row = $.extend({}, row ? row : {}, {ids: ids});
                        var url = options.extend.audit_url;
                        Fast.api.open(Table.api.replaceurl(url, row, table), __('审核'), $(this).data() || {});
                    },
                    'click .btn-delone': function (e, value, row, index) {
                        e.stopPropagation();
                        e.preventDefault();
                        var that = this;
                        var top = $(that).offset().top - $(window).scrollTop();
                        var left = $(that).offset().left - $(window).scrollLeft() - 260;
                        if (top + 154 > $(window).height()) {
                            top = top - 154;
                        }
                        if ($(window).width() < 480) {
                            top = left = undefined;
                        }
                        Layer.confirm(
                            __('Are you sure you want to delete this item?'),
                            {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true},
                            function (index) {
                                var table = $(that).closest('table');
                                var options = table.bootstrapTable('getOptions');
                                Table.api.multi("del", row[options.pk], table, that);
                                Layer.close(index);
                            }
                        );
                    }
                },
            },
            defaultdate: function () {
                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;//获取当前月份(0-11,0代表1月)
                if (month >= 10) {
                    month = "" + month;
                } else {
                    month = "0" + month;
                }
                return year + "-" + month;
            },
            showMonthFirstDay: function () {
                var Nowdate = new Date();
                var MonthFirstDay = new Date(Nowdate.getFullYear(), Nowdate.getMonth(), 1);
                M = Number(MonthFirstDay.getMonth()) + 1
                return MonthFirstDay.getFullYear() + "-" + M + "-" + MonthFirstDay.getDate() + ' 00:00:00';
            },
            showMonthLastDay: function () {
                var Nowdate = new Date();
                var MonthNextFirstDay = new Date(Nowdate.getFullYear(), Nowdate.getMonth() + 1, 1);
                var MonthLastDay = new Date(MonthNextFirstDay - 86400000);
                M = Number(MonthLastDay.getMonth()) + 1
                return MonthLastDay.getFullYear() + "-" + M + "-" + MonthLastDay.getDate() + ' 23:59:59';
            },
            defaultdate2: function () {
                //2019-07-01 00:00:00 - 2019-07-31 23:59:59
                var MonthFirstDay = Controller.api.showMonthFirstDay();
                var MonthLastDay = Controller.api.showMonthLastDay();

                return MonthFirstDay + " - " + MonthLastDay;
            },
            valuechanged: function () {
                var r_wages = parseFloat($("#c-r_wages").val());
                var tax = parseFloat($("#c-tax").val());

                var totalwages = Controller.api.TransJine(r_wages + tax);
                $("#c-totalwages").val(totalwages);
            },
            TransJine: function (d) {
                return Math.round(d * 100) / 100;
            },
            TransGeshui: function (d) {
                d = d - 5000;
                if (d <= 0)
                    return 0;
                else if (d <= 3000)
                    return d * 0.03;
                else if (d <= 12000)
                    return d * 0.1 - 210;
                else if (d <= 25000)
                    return d * 0.2 - 1410;
                else if (d <= 35000)
                    return d * 0.25 - 2660;
                else if (d <= 55000)
                    return d * 0.3 - 4410;
                else if (d <= 80000)
                    return d * 0.35 - 7160;
                else
                    return d * 0.45 - 15160;
            },
            formatter: {//渲染的方法
                paystatus: function (value, row, index) {
                    if (row.paystatus == '办理失败' ) {
                        return [
                            '<a href="javascript:;" class="paystatus text-danger" data-id= "' + row.id + '" > ' + row.paystatus + '</a>'
                        ].join("")

                    }  else if (row.paystatus == '未办理') {
                        return [
                            '<a href="javascript:;" class="paystatus text-warning" data-id= "' + row.id + '" > ' + row.paystatus + '</a>'
                        ].join("")

                    }  else {
                        return [
                            '<a href="javascript:;" class="paystatus" data-id= "' + row.id + '" > ' + row.paystatus + '</a>'
                        ].join("")
                    }
                },
                tkstatus: function (value, row, index) {
                    if (row.refundornot == '已退款') {
                        return [
                            '<a href="javascript:;" class="tkstatus text-success" data-id= "' + row.id + '" > ' + row.refundornot + '</a>'
                        ].join("")

                    }  else if (row.refundornot == '待退款') {
                        return [
                            '<a href="javascript:;" class="tkstatus text-warning" data-id= "' + row.id + '" > ' + row.refundornot + '</a>'
                        ].join("")

                    }  else if (row.refundornot == '需退款') {
                        return [
                            '<a href="javascript:;" class="tkstatus text-danger" data-id= "' + row.id + '" > ' + row.refundornot + '</a>'
                        ].join("")

                    }  else {
                        return [
                            '<a href="javascript:;" class="tkstatus" data-id= "' + row.id + '" > -- </a>'
                        ].join("")
                    }
                }
            }
        }
    };
    return Controller;
});